<?php

namespace App\Http\Controllers\Api;

use App\Model\ApkUpload;
use App\Model\Card;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Model\Switched;
use App\Http\Service\ServiceLogin;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Route;

class VerifyController extends Controller
{
    use ServiceLogin;

    public function __construct(Request $request){
        $this->request = $request;
    }

    /**
     * app景区登录
     * czs
     */
    public function login(Request $request) {
        $account = $request->input('account');
        $password = $request->input('password');
        $result = $this->operatorLoginApi($account,$password);
        return $result->getResult();
    }
    /**
     * @param Request $request
     * @return array|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
     * 卡号验证
     * czs
     */
    public function check(Request $request){
        $cardNum = $request->input('card_num');
        $password = $request->input('password');
        $sceneryId = $request->input('scenery_id');
        $res = Card::verifyApi($cardNum,$password,$sceneryId);
        return $res->getResult();
    }

    /**
     * @return array
     * 核销
     * czs
     */
    public function verify(Request $request)
    {
        $cardNum = $request->input('card_num');
        $password = $request->input('password');
        $sceneryId = $request->input('scenery_id');
        $res = Card::verifyFinalApi($cardNum,$password,$sceneryId);
        return $res->getResult();
    }

    /**
     * @param Request $request
     * @return mixed
     * 查询记录
     * czs
     */
    public function search(Request $request){
        $sceneryId = $request->input('scenery_id');
        $startTime = $request->input('start_time');
        $endTime = $request->input('end_time');
        $res = Card::verifyListApi($sceneryId,$startTime,$endTime);
        return $res->getResult();
    }

    /**
     * @param Request $request
     * @return mixed
     * 安卓apk升级
     * czs
     */
    public function upgrade(){
        $res = ApkUpload::getApk();
        return $res->getResult();
    }
}
